from time import sleep, time


def calc_time(fun):
    def wrapper(*args , **kwargs):
        before = time()
        # print('开始计时')
        result = fun(*args , **kwargs)
        after = time()
        # print('计时结束')
        print("play了%d秒" % (after - before))
        return result
    return wrapper
@calc_time
def play(game , t):
    print('start game %s' % game)
    sleep(t)
    print('game over')

    return 'happy'

if __name__ == '__main__':
    result = play('sakdjflsa' , 2)
    print(result)
